var UserCon = iClass.get("User");
iClass.method("Friend", {
	initInfo: function(info) {
		if (db.find_one(this.dbname, {
				user_id: info.user_id,
				friend_id: info.friend_id
			})) {
			Throw("已经是好友关系");
		}
		if (!UserCon.hasById(info.user_id)) {
			Throw("设定好友关系：找不到指定用户（所属者）")
		}
		this.user_id = info.user_id;
		if (!UserCon.hasById(info.friend_id)) {
			Throw("设定好友关系：找不到指定用户（好友）")
		}
		this.friend_id = info.friend_id;

		this.save();
	},
	getDetail: function() {
		var res = this.clone();
		res.friend = UserCon.get(this.friend_id);
		return res;
	}
});